package test;

import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.client.HBaseAdmin;

import java.io.IOException;

public class APIDemo1 {

    //判断表是否存在(旧版API)
    public static boolean isTableExist(String tableName) throws IOException {
        HBaseConfiguration conf = new HBaseConfiguration();
        conf.set("hbase.zookeeper.quorum","master,slave1,slave2");
        HBaseAdmin admin = new HBaseAdmin(conf);
        boolean result = admin.tableExists(tableName);
        return result;
    }


    public static void main(String[] args) throws IOException {
        System.out.println(isTableExist("student"));//true
        System.out.println(isTableExist("xxxxxxx"));//false
    }
}
